﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace LojaEmDia.Cadastro
{
    public partial class frmFabricante : LojaEmDia.Cadastro.frmBasePopUp
    {
        public frmFabricante()
        {
            InitializeComponent();

            this.Carregar();
        }

        private void Carregar()
        {
            this.bindingSource1.DataSource = Negocio.Faced.NegocioFaced.Me.ListarFabricante();
            this.dataGridView1.AutoGenerateColumns = false;
            DataGridViewTextBoxColumn colNome = new DataGridViewTextBoxColumn();
            colNome.HeaderText = "Nome";
            colNome.DataPropertyName = "Nom_fabricante";
            this.dataGridView1.Columns.Add(colNome);
        }

        protected override void OnSave(object sender, EventArgs e)
        {

            try
            {
               this.bindingSource1.EndEdit();
               List<Negocio.FABRICANTE> lista = (List<Negocio.FABRICANTE>)this.bindingSource1.DataSource;
               Negocio.Faced.NegocioFaced.Me.Salvar( lista );
                
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erro na operação", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            base.OnSave(sender, e);


        }
    }
}
